
package service;


import service.OrderService;
import org.springframework.stereotype.Service;

@Service("orderService") // 明确指定bean名称
public class OrderServiceImpl implements OrderService {

    @Override
    public void add(String pname, int number) {
        System.out.println("添加商品: " + pname + ", 数量: " + number);
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }

    @Override
    public void delete(String pname) {
        System.out.println("删除商品: " + pname);
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }

    @Override
    public int find(String pname) {
        System.out.println("查询商品: " + pname);
        try {
            Thread.sleep(30);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
        return (int) (Math.random() * 10);
    }
}